class Solution {
public:
    int sumOddLengthSubarrays(vector<int>& arr) {
        int size=arr.size();
        int result=0;
        for(int i=0;i<size;i++){
            int left=i;                 
            int right=size-left-1;      
            int leftodd=(left+1)/2;
            int rightodd=(right+1)/2; 
            int lefteven=left/2+1;
            int righteven=right/2+1;
            result+=(leftodd*rightodd +lefteven*righteven)*arr[i];
        }
    return result;
    }
};
